﻿using MessageQuque.Business.Model;
using MessageQuque.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MessageQuqueTester
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("<请输入发送到队列的消息内容>\r\n");
            while (true)
            {
                try
                {
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write("> ");

                    var model = new TestModel();

                    model.Message = Console.ReadLine();

                    if (string.IsNullOrWhiteSpace(model.Message))
                        continue;

                    var sender = new Sender<TestModel>();

                    sender.Enqueue(model);

                    Console.ForegroundColor = ConsoleColor.DarkGreen;

                    Console.WriteLine("\r\n成功: 消息\"{0}\"已发送到队列服务器\r\n", model.Message);
                }
                catch (Exception e)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(e.Message);
                    Console.WriteLine();
                }
            }
        }
    }
}
